<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./indexT.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                >



    <ui:define name="content">


        <h:form id="myform">  


            <p:toolbar>  
                <p:toolbarGroup align="left">  
                    <p:commandButton value="Cliente" icon="ui-icon-extlink"  onclick="dlg.show()" >  

                    </p:commandButton> 
                    <p:commandButton value="Lavorazioni" icon="ui-icon-extlink"  onclick="lav.show()">  

                    </p:commandButton> 
                </p:toolbarGroup>  



            </p:toolbar>  




            <p:growl id="growl" showDetail="true" />  


            <h:messages errorClass="error"/>  
            <p:dialog id="dialog" header="Clienti" widgetVar="dlg" resizable="false" width="500px;" modal="true" >  
                <!--
                                <p:ajax event="rowSelect" listener="#{tableBean.onRowSelect}"   
                                        update=":form:display :form:growl" oncomplete="carDialog.show()" />  
                                <p:ajax event="rowUnselect" listener="#{tableBean.onRowUnselect}" update=":form:growl"/> 
                -->
                <h:panelGrid columns="2" columnClasses="label, value" styleClass="grid">  
                    <p:dataTable id="dataTable" var="c" value="#{clienti.allClienti}" widgetVar="clientiTable"   
                                 emptyMessage="Nessun cliente trovato" filteredValue="#{clienti.fcli}" paginator="true" rows="5"
                                 selectionMode="single"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                 selection="#{clienti.cliente}"
                                 rowKey="#{c.idCliente}"

                                 >  
                        <p:ajax event="rowSelect" update=":myform:dettaglio" oncomplete="dlg.hide()"/>

                        <p:column id="yearColumn" filterBy="#{c.cognome}"  
                                  filterMatchMode="contains"
                                  headerText="Cognome" footerText="Cognome">  
                            <h:outputText value="#{c.cognome}" />  
                        </p:column>  


                        <p:column id="modelColumn" filterBy="#{c.nome}"   
                                  headerText="Nome" footerText="Nome"  
                                  filterMatchMode="startsWith">  
                            <h:outputText value="#{c.nome}" />  
                        </p:column>  

                        <p:column id="scontrini" 
                                  headerText="Scontrini" footerText="Scontrini">  

                            <h:outputText value="#{c.scontrini.size()}" />  
                        </p:column>  

                    </p:dataTable>  


                </h:panelGrid>  
            </p:dialog> 


            <h:messages errorClass="error"/>  
            <p:dialog id="dialogLav" header="Lavorazioni" widgetVar="lav" resizable="false" width="500px;">
                <h:panelGrid columns="2" columnClasses="label, value">  


                    <p:dataTable id="dataTable2" var="c" value="#{clienti.allLavorazioni}" widgetVar="clientiTable2"   
                                 emptyMessage="No cars found with given criteria" filteredValue="#{clienti.flt}" paginator="true" rows="4"
                                 selectionMode="single"
                                 selection="#{clienti.lavorazioniTipi}"
                                 rowKey="#{c.idTipoLavorazione}"
                                 resizableColumns="no" style="width:1100px;">  
                        <p:ajax event="rowSelect" update=":myform:dataTable3 :myform:dettaglio" />
                        <!-- f:facet name="header">  
                            <p:outputPanel>  
                                <h:outputText value="Search all fields:" />  
                                <p:inputText id="globalFilter" onkeyup="clienti.filter()" style="width:150px" />  
                            </p:outputPanel>  
                        </f:facet -->  

                        <p:column id="lavorazioneDesc" filterBy="#{c.tipoLavorazione}"  
                                  headerText="Lavorazione" footerText="Lavorazione"
                                  filterMatchMode="contains" width="250px">  
                            <h:outputText value="#{c.tipoLavorazione}" />  
                        </p:column>  

                        <p:column id="capi" filterBy="#{c.capo.descrizione}"  
                                  headerText="Capo" footerText="Capo" width="250px">  
                            <h:outputText value="#{c.capo.descrizione}" />  
                        </p:column>  


                        <p:column id="idLavCat" filterBy="#{c.lavCat.categoriaLav}"   
                                  headerText="Categoria" footerText="Categoria"  
                                  width="250px">  
                            <h:outputText value="#{c.lavCat.categoriaLav}" />  
                        </p:column>  



                    </p:dataTable>  
                </h:panelGrid>  




            </p:dialog>



            <p:fieldset legend="Dettagli cliente" toggleable="true" toggleSpeed="500" id="dettaglio">  
                <h:panelGrid columns="4" cellpadding="10">  
                    <h:outputText  id="nomeCliente" value="#{clienti.cliente.nome}"/>  
                    <h:outputText  id="cognomeCliente" value="#{clienti.cliente.cognome}"/>  
                    <h:outputText  id="totale" value="totale"/>  
                    <h:outputText  id="totaleValue" value="#{clienti.totale}"/>  

                </h:panelGrid>  
            </p:fieldset>  

            <p:dataTable id="dataTable3" var="c" value="#{clienti.mediumLTModel}" widgetVar="clientiTable3"   
                         emptyMessage="Nessuna lavorazione inserita" 
                         selection="#{clienti.lavorazioniArray}"
                         resizableColumns="no" style="width:1100px;"
                         rowKey="#{c.idTipoLavorazione}"
                          >  
                <p:column selectionMode="multiple" style="width:2%" /> 

                <p:column id="lavorazioneDesc"  
                          headerText="Lavorazione" 
                          width="250px">  
                    <h:outputText value="#{c.tipoLavorazione}" />  
                </p:column>  

                <p:column id="capi" 
                          headerText="Capo"  width="250px">  
                    <h:outputText value="#{c.capo.descrizione}" />  
                </p:column>  


                <p:column id="idLavCat"    
                          headerText="Categoria" 
                          width="250px">  
                    <h:outputText value="#{c.lavCat.categoriaLav}" />  
                </p:column>  
                <p:column id="prezzo"  
                          headerText="Lavorazione" 
                          width="250px">  
                    <p:cellEditor>  
                        <f:facet name="output"><h:outputText  value="#{c.prezzo}" /></f:facet>  
                        <f:facet name="input"><p:inputMask value="#{c.prezzo}" mask="9*.9999"/>  </f:facet>  
                    </p:cellEditor>  

                </p:column>  

            </p:dataTable> 
                <p:commandButton value="Elimina" id="ajax"   disabled="false"
                                 actionListener="#{clienti.delete}"    styleClass="ui-priority-primary"/>  

        </h:form>  
    </ui:define>


</ui:composition>
